package edu.chl.hajo.wss;

import edu.chl.hajo.shop.core.Product;
import javax.xml.bind.annotation.*;

/**
 * Need this because translation from XML to JSON
 *
 * @author hajo
 */
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlType(name="Product")
public class ProductProxy {

    // The wrapped product
    private Product product;

    protected ProductProxy() { // Must have
    }

    public ProductProxy(Product product) {
        if (product == null)
            throw new IllegalArgumentException("Product was null");
        
        this.product = product;
    }

    @XmlElement(required = true)
    public String getName() {
        return product.getName();
    }

    @XmlElement(required = true)
    public Long getId() {
        return product.getId();
    }

    @XmlElement(required = true)
    public double getPrice() {
        return product.getPrice();
    }
}
